{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f3bf720b",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy.matlib # Can be used to test with Matlab code\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ae21823f",
   "metadata": {},
   "outputs": [],
   "source": [
    "#Class for Making an Empty Particle\n",
    "class MakeEmptyParticles:\n",
    "    def __init__(self):\n",
    "        self.Position=[]\n",
    "        self.Velocity=[]\n",
    "        self.Cost=[]\n",
    "        self.Dominated=False\n",
    "        self.Best = {}\n",
    "        self.Best['Position']=[]\n",
    "        self.Best['Cost']=[]\n",
    "        self.GridIndex=[]\n",
    "        self.GridSubIndex=[]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "d955827d",
   "metadata": {},
   "outputs": [],
   "source": [
    "def CreateEmptyParticles(n=1):\n",
    "    particles = []\n",
    "    for i in range(n):\n",
    "        particles.append(MakeEmptyParticles())\n",
    "    particles = np.asarray(particles) #Done according to the code, can be changed if it needs a single array\n",
    "    return particles\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "368d44d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "particles = CreateEmptyParticles(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4ae6e138",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([<__main__.MakeEmptyParticles object at 0x000001FBE1767250>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE17674F0>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE17674C0>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE1767400>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE1767610>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE17670D0>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE17676D0>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE1767700>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE1767070>,\n",
       "       <__main__.MakeEmptyParticles object at 0x000001FBE17675B0>],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particles"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "657edf42",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particles[1].Dominated"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "a0a391e8",
   "metadata": {},
   "outputs": [],
   "source": [
    "particles[1].Dominated = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "db5739fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particles[1].Dominated"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "b17da14e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particles[2].Dominated"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "48dc96f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(10, 1)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particles.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "2c50fed6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.size(particles)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "4c5334bb",
   "metadata": {},
   "outputs": [],
   "source": [
    "import inspect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "8320a1a8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inspect.isclass(particles[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "642e049c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<__main__.MakeEmptyParticles at 0x2aa71fe2280>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "particles[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5257d4e0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
